package net.mobgame.internet;

import net.mobgame.android.R;
import net.mobgame.common.Utils;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.style.UnderlineSpan;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;

public class NoInternetActivity extends Activity{

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.no_internet);

		ImageView imgTryAgain = (ImageView)findViewById(R.id.imgNoInternet);
		SpannableString content = new SpannableString("Try Again");
		content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
		imgTryAgain.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if(Utils.isOnline(getApplicationContext())) {
					finish();
				}
			}
		});
	}

	@SuppressWarnings("deprecation")
	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub

		final AlertDialog dlgExit = new AlertDialog.Builder(this).create();
		dlgExit.setMessage("Do you want to quit app?");
		dlgExit.setButton("Yes", new DialogInterface.OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				moveTaskToBack(true);
			}
		});
		dlgExit.setButton2("No", new DialogInterface.OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				dlgExit.dismiss();
			}
		});
		dlgExit.show();
	}


}
